<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>jQuery请求Ajax</title>

    <!-- crossorigin不引入https://cdn.bootcdn.net的token信息，取消浏览器log时的警告 -->
    <link crossorigin="anonymous" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.6.1/css/bootstrap.min.css" rel="stylesheet">
    <script crossorigin="anonymous" src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>

<body>

    <div class="container">
        <h2 class="page-item">jQuery发送Ajax请求</h2>
        <button class="btn btn-primary">GET请求</button>
        <button class="btn btn-danger">POST请求</button>
        <button class="btn btn-success">通用请求</button>
    </div>

    <script>
        $('button').eq(0).click(function() {
            $.get('http://127.0.0.1:9999/jquery_server', {
                a: 100,
                b: 200
            }, function(data) {
                console.log(data);
            }, 'json')
        })

        $('button').eq(1).click(function() {
            $.post('http://127.0.0.1:9999/jquery_server', {
                a: 100,
                b: 200
            }, function(data) {
                console.log(data);
            }, 'json')
        })

        $('button').eq(2).click(function() {
            $.ajax({
                url: 'http://127.0.0.1:9999/jquery_server',
                data: {
                    a: 100,
                    b: 200
                },
                type: 'json',
                timeout: function() {

                },
                error: function() {

                },
                success: function() {

                },
                headers: {

                }
            })
        })
    </script>
</body>

</html>